#include<bits/stdc++.h>
#define int long long
#define double long double
#define N 1000005
using namespace std;
int n;
int h[N],r[N],R[N];
double w[N],ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-f;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*f;
}
signed main(){
    freopen("wan.in","r",stdin);
    freopen("wan.out","w",stdout);
    n=read();
    for(int i=1;i<=n;i++){
        h[i]=read();
        r[i]=read();
        R[i]=read();
    }
    if(n<=3000){
        for(int i=1;i<=n;i++){
            for(int j=1;j<i;j++){
                if(r[i]>=R[j]){w[i]=max(w[i],w[j]+h[j]);continue;}
                w[i]=max(w[i],w[j]);
                if(r[i]>=r[j]) w[i]=max(w[i],w[j]+(double)h[j]/(R[j]-r[j])*(r[i]-r[j]));
                if(R[j]>=r[i]&&R[i]>=R[j]) w[i]=max(w[i],w[j]+h[j]-(double)h[i]/(R[i]-r[i])*(R[j]-r[i]));
                if(R[i]>=r[j]&&R[i]<=R[j]) w[i]=max(w[i],w[j]-h[i]+(double)h[j]/(R[j]-r[j])*(R[i]-r[j]));
            }
            ans=max(ans,w[i]+h[i]);
        }
        printf("%.12Lf",ans);
        return 0;
    }
    for(int i=1;i<=n;i++){
        for(int j=max(1ll,i-200);j<i;j++){
            if(r[i]>=R[j]){w[i]=max(w[i],w[j]+h[j]);continue;}
            w[i]=max(w[i],w[j]);
            if(r[i]>=r[j]) w[i]=max(w[i],w[j]+(double)h[j]/(R[j]-r[j])*(r[i]-r[j]));
            if(R[j]>=r[i]&&R[i]>=R[j]) w[i]=max(w[i],w[j]+h[j]-(double)h[i]/(R[i]-r[i])*(R[j]-r[i]));
            if(R[i]>=r[j]&&R[i]<=R[j]) w[i]=max(w[i],w[j]-h[i]+(double)h[j]/(R[j]-r[j])*(R[i]-r[j]));
        }
        ans=max(ans,w[i]+h[i]);
    }
    printf("%.12Lf",ans);
    return 0;
}